<template>
  <div>
    <el-card class="small-card" v-if="hasCard">
      <el-form :inline="true" :model="form" class="demo-form-inline">
        <slot name="item"></slot>
      </el-form>
      <div>
        <slot name="btns" style="float: left;margin-bottom: 10px;"></slot>
        <div style="float: right">
          <el-button type="primary" @click="onSubmit">查询</el-button>
          <el-button @click="resetForm('from')">重置</el-button>
        </div>
        <div style="clear: both"></div>
      </div>
    </el-card>
    <div v-else>
      <el-form :inline="true" :model="form" class="demo-form-inline">
        <slot name="item"></slot>
      </el-form>
      <div>
        <slot name="btns" style="float: left;margin-bottom: 10px;"></slot>
        <div style="float: right">
          <el-button type="primary" @click="onSubmit">查询</el-button>
          <el-button @click="resetForm('from')">重置</el-button>
        </div>
        <div style="clear: both"></div>
      </div>
    </div>
  </div>
</template>

<script>
  export default {
    data() {
      return {
        form: {}
      }
    },
    computed: {},
    props: {
      value: {Object, default: {}},
      hasCard: {Boolean, default: true}
    },
    mounted() {
      this.form = this.value
    },
    methods: {
      onSubmit() {
        this.$emit('input', this.form)
        this.$emit('submit')
      },
      resetForm(formName) {
        this.form = {}
        this.$emit('input', this.form)
        this.$emit('reset')
      }
    }
  }
</script>
<style lang="scss" scoped>
  .small-card {
    ::v-deep .el-card__body {
      padding: 10px;
    }
  }

  .el-form {
    ::v-deep .el-form-item {
      margin-bottom: 10px;
    }
  }
</style>
